home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / ANIVGA.ARJ / EXAMPLE1.PAS < prev    next >
Pascal/Delphi Source File  |  1991-11-09  |  1KB  |  53 lines

  1. PROGRAM Example1;
  2. USES ANIVGA,CRT;
  3. CONST LoadNumber=42; {why not 42?}
  4.       SpriteName='FLOWER.COD'; {Path and name of the sprite to load}
  5.       Sprite1=0;
  6.       Sprite2=5;
  7. VAR ch:CHAR;
  8.     collide:BOOLEAN;
  9.  
  10. BEGIN
  11.  IF loadSprite(SpriteName,LoadNumber)=0
  12.   THEN BEGIN
  13.         CloseRoutines;
  14.         WRITELN('Error: '+GetErrorMessage); halt(1)
  15.        END;
  16.  
  17.  InitGraph;
  18.  
  19.  Color:=66;
  20.  BackgroundLine(0,0,XMAX,0); BackgroundLine(XMAX,0,XMAX,YMAX);
  21.  BackgroundLine(XMAX,YMAX,0,YMAX); BackgroundLine(0,YMAX,0,0);
  22.  BackgroundOutTextXY(100,70,'Hello world!');
  23.  
  24.  SpriteN[Sprite1]:=LoadNumber;
  25.  SpriteX[Sprite1]:=0; SpriteY[Sprite1]:=0;
  26.  
  27.  SpriteN[Sprite2]:=LoadNumber;
  28.  SpriteX[Sprite2]:=XMAX SHR 1; SpriteY[Sprite2]:=YMAX SHR 1;
  29.  
  30.  WHILE KeyPressed DO ch:=ReadKey;
  31.  Animate;
  32.  REPEAT
  33.   collide:=Hitdetect(Sprite1,Sprite2);
  34.   if collide THEN BEGIN Sound(1000); Delay(5); NoSound END;
  35.   if KeyPressed
  36.    THEN BEGIN
  37.          WHILE KeyPressed do ch:=UpCase(ReadKey);
  38.          CASE ch OF
  39.           'I':DEC(SpriteY[0]);
  40.           'J':DEC(SpriteX[0]);
  41.           'K':INC(SpriteX[0]);
  42.           'M':INC(SpriteY[0]);
  43.           'A':DEC(StartVirtualX,10);
  44.           'S':DEC(StartVirtualX,10);
  45.          END;
  46.          IF POS(ch,'IJKMAS')>0 THEN Animate;
  47.         END;
  48.  
  49.  UNTIL ch='Q';
  50.  
  51.  CloseRoutines;
  52. END.
  53.